// run: $exec < input
#include <cstdio>
#include <string.h>
#include <algorithm>
#define MAXN 100010
using namespace std;
int n, m;
int f1, f2, ind, e;
int head[MAXN],ne[MAXN*7], dfn[MAXN], low[MAXN],p[MAXN*7], col[MAXN];
int odd[MAXN], even[MAXN];
void init(){
	e=ind=0;
	memset(odd, 0, sizeof(odd));
	memset(even, 0, sizeof(even));
	memset(head, -1, sizeof(head));
	memset(dfn, -1, sizeof(dfn));
}
void addnote(int u, int v){
	p[e]=v;
	ne[e]=head[u];
	head[u]=e++;
}
void dfs(int x, int fa, int cl){
	dfn[x]=++ind;
	low[x]=dfn[x];
	col[x]=cl;
	for (int i=head[x];i+1;i=ne[i]){
		int v=p[i];
		if (v==fa) continue;
		if (dfn[v]==-1){
			dfs(v, x, 1-cl);
			low[x]=min(low[x], low[v]);
		}
		else{
			if (dfn[x]>dfn[v] && col[v]==cl) odd[x]++;
			else if (dfn[x]>dfn[v] && col[v]!=cl) even[x]++;
			low[x]=min(low[x], dfn[v]);
		}
	}
	if (low[x]<dfn[x]){
		odd[fa]=(odd[fa] + odd[x]);
		even[fa]=(even[fa] + even[x]);
	}
	if (odd[x]) f1=1;
	if (even[x] || odd[x]>1) f2=1;
}
int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		init();
		f1=f2=0;
		scanf("%d%d", &n, &m);
		for (int i=0;i<m;i++){
			int x, y;
			scanf("%d%d", &x, &y);
			addnote(x, y);
			addnote(y, x);
		}
		for (int i=1;i<=n;i++)
			if (dfn[i]==-1)
				dfs(i, 0, 0);
		if (f1) printf("YES\n");
		else printf("NO\n");
		if (f2) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
